from channels.generic.websocket import AsyncJsonWebsocketConsumer

class PostSyncConsumer(AsyncJsonWebsocketConsumer):
    async def connect(self):
        await self.channel_layer.group_add("post_sync", self.channel_name)
        await self.accept()

    async def disconnect(self, close_code):
        await self.channel_layer.group_discard("post_sync", self.channel_name)

    async def post_update(self, event):
        await self.send_json(event["data"])